package com.ruoyi.web.controller.source;


import cn.hxzy.common.OperateType;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hxzy.source.entity.TtSourceOperation;
import com.hxzy.source.service.TtSourceOperationService;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.DataSourceType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author mingqian.Wu
 * @since 2023-06-26
 */
@RestController
@RequestMapping("/ttSourceOperation")
@DataSource(DataSourceType.SOURCE)
public class TtSourceOperationController {

    @Autowired
    private TtSourceOperationService ttSourceOperationService;



    @GetMapping("/getSourceOperationByType/{type}/{id}")
    public AjaxResult getSourceOperationByType(@PathVariable Integer  type,@PathVariable String id){
        QueryWrapper<TtSourceOperation>queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("operation_type",type);
        queryWrapper.eq("source_id",id);
        List<TtSourceOperation> list = ttSourceOperationService.list(queryWrapper);
        list.stream().forEach(item->{
            item.setOperationTypeName(OperateType.geOperateTypeValue(item.getOperationType()));
        });
        return AjaxResult.success(list);
    }


}

